package com.android.gpuimage;

import android.annotation.SuppressLint;

/**
 * 高斯模糊（选择区域不模糊）滤镜
 */
@SuppressLint("WrongCall")
public class GPUImageGaussianSelectiveBlurFilter extends GPUImageFilterGroup {

    private GPUImageSelectiveBlurFilter mSelectiveFilter;
    private GPUImageGaussianBlurFilter mBlurFilter;

    public GPUImageGaussianSelectiveBlurFilter(int defaultX, int defaultY) {
        super(null);
        mBlurFilter = new GPUImageGaussianBlurFilter(2.0f);
        mSelectiveFilter = new GPUImageSelectiveBlurFilter(defaultX, defaultY);
        addFilter(mBlurFilter);
        addFilter(mSelectiveFilter);
    }

    public void setExcludeCircleRadius(float radius) {
        mSelectiveFilter.setExcludeCircleRadius(radius);
    }

    public float getExcludeCircleRadius() {
        return mSelectiveFilter.getExcludeCircleRadius();
    }

    public boolean scaleExcludeCircle(float scale) {
        return mSelectiveFilter.scaleExcludeCircle(scale);
    }

    public float getExcludeCircle() {
        return mSelectiveFilter.getExcludeCircle();
    }

    public float getFoucsX() {
        return mSelectiveFilter.getFoucsX();
    }

    public float getFoucsY() {
        return mSelectiveFilter.getFoucsY();
    }

    public void setExcludeCirclePoint(float x, float y) {
        mSelectiveFilter.setExcludeCirclePoint(x, y);
    }

    public void setExcludeBlurSize(float size) {
        mSelectiveFilter.setExcludeBlurSize(size);
    }

    public float getExcludeBlurSize() {
        return mSelectiveFilter.getExcludeBlurSize();
    }

    public void setAspectRatio(float ratio) {
        mSelectiveFilter.setAspectRatio(ratio);
    }

    public float getAspectRatio() {
        return mSelectiveFilter.getAspectRatio();
    }
    
    public void setBlurSize(float value) {
        mBlurFilter.setBlurSize(value);
    }

    public float getBlurSize() {
        return mBlurFilter.getBlurSize();
    }
    
    public void setPressed(boolean value) {
        mSelectiveFilter.setPressed(value);
    }

    public void setShowTIpShadow(boolean show) {
        mSelectiveFilter.setShowTIpShadow(show);
    }

    public boolean isPressed() {
        return mSelectiveFilter.isPressed();
    }

    public void copy(GPUImageGaussianSelectiveBlurFilter filter) {
        setExcludeCircleRadius(filter.getExcludeCircleRadius());
        setExcludeCirclePoint(filter.getFoucsX(), filter.getFoucsY());
        setExcludeBlurSize(filter.getExcludeBlurSize());
        setAspectRatio(filter.getAspectRatio());
        setBlurSize(filter.getBlurSize());
    }

    public void copyFromData(float[] data) {
        if (data != null && data.length >= 6) {
            setExcludeCircleRadius(data[0]);
            setExcludeCirclePoint(data[1], data[2]);
            setExcludeBlurSize(data[3]);
            setAspectRatio(data[4]);
            setBlurSize(data[5]);
        }
    }

    public float[] copyData() {
        float[] ret = new float[6];
        ret[0] = getExcludeCircleRadius();
        ret[1] = getFoucsX();
        ret[2] = getFoucsY();
        ret[3] = getExcludeBlurSize();
        ret[4] = getAspectRatio();
        ret[5] = getBlurSize();
        return ret;
    }
}
